package com.sh.aspects;

import com.sh.utils.JmsMessageProducer;
import org.aspectj.lang.JoinPoint;
import org.aspectj.lang.annotation.AfterReturning;
import org.aspectj.lang.annotation.Aspect;
import org.aspectj.lang.annotation.Pointcut;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.core.annotation.Order;
import org.springframework.stereotype.Component;

@Aspect
@Component
@Order(10)
public class ResorderEmailAspect {


    @Autowired
    private JmsMessageProducer jmsMessageProducer;


//    confirmOrder

    @Pointcut("execution(* com.sh.service.impl.ResorderBizImpl.order(..))")
    private void confirmOrder() {
    }



    @Pointcut("confirmOrder()")
    private void all() {
    }

    @AfterReturning("all()")
    public void after(JoinPoint joinPoint) {
        System.out.println("=======================================");
        System.out.println(joinPoint);
//        Object[] args = joinPoint.getArgs();
//        int accountId = (int) args[0];  // 账户id
//        double money = (double) args[1];  // 金额
//        int toAccountId;
//        if (joinPoint.getSignature().getName().equals("transfer")) {
//            toAccountId = (int) args[2];  // 目标账户id
//        } else {
//            toAccountId = 0;  // 目标账户id
//        }
//        Account account = bankBiz.findAccount(accountId);
//        String mail = account.getMail();
//        String methodName = joinPoint.getSignature().getName();
//
//        jmsMessageProducer.sendMessage(new MessageBean(account, money, toAccountId, mail, methodName));

    }
}
